package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.HobbyDictMapper;
import com.ghck.server.model.HobbyDict;
import com.ghck.server.model.query.HobbyDictQuery;
import com.ghck.server.service.HobbyDictService;

/**
 * 爱好  <br>
 * dict_hobby <br>
 * v1.0 2016-05-01
 */
 @Service
 @Transactional
 public class HobbyDictServiceImpl implements HobbyDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(HobbyDictServiceImpl.class);
	
	@Autowired
	private HobbyDictMapper hobbyDictMapper;
	
	/**
 	*根据ID删除 爱好
 	*/
 	@Override
 	public Integer deleteHobbyDictById(Integer id){
 		return hobbyDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 爱好
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertHobbyDict(List<? extends HobbyDict> hobbyDicts){
		Integer count = hobbyDictMapper.batchInsert(hobbyDicts);
		return count;
 	}
 	/**
 	*新增 爱好
 	*/
 	@Override
 	@Transactional
 	public Integer insertHobbyDict(HobbyDict domain){
		Integer id = hobbyDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 爱好
 	*/
 	@Override
 	@Transactional
 	public Integer updateHobbyDict(HobbyDict domain){
		Integer count = hobbyDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 爱好
 	*/
 	public HobbyDict findHobbyDictById(Integer id){
 		HobbyDict result = hobbyDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 爱好
 	*/
	public List<HobbyDict> findHobbyDictByQuery(HobbyDictQuery query){
		query.dealWith();
		List<HobbyDict> result = hobbyDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (HobbyDict hobbyDict : result) {
				hobbyDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countHobbyDictByQuery(HobbyDictQuery query){
 		query.dealWith();
 		Integer result = hobbyDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<HobbyDict> findHobbyDictByIds(List<Integer> ids){
 		List<HobbyDict> result = hobbyDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (HobbyDict hobbyDict : result) {
				hobbyDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public HobbyDict findByName(String name){
		HobbyDict result = hobbyDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<HobbyDict> findAll(){
		List<HobbyDict> result = hobbyDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (HobbyDict hobbyDict : result) {
				hobbyDict.dealWith();
			}
		}
		return result;
	}
}	